<% layout('/layouts/default.html', {title: '车辆档案管理', libs: ['validate','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(tcar.isNewRecord ? '新增车辆档案' : '编辑车辆档案')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${tcar}" action="${ctx}/base/cars/tcar/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('显示名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:hidden path="isNewRecord"/>
								<#form:input path="carName" maxlength="100" readonly="true" placeholder="自动保存" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('车辆编号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:hidden path="isNewRecord"/>
							<#form:input path="carId" maxlength="64" readonly="true" placeholder="自动编号" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('品牌')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="brand" dictType="car_pinpai" class="form-control required" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('能源类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="energyType" dictType="car_nengyuanleixing" class="form-control required" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('车型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="model" maxlength="100" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('年款')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="year" dictType="car_niankuan" class="form-control required" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('英文名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="englishName" maxlength="100" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('区域')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="area" dictType="car_quyu" class="form-control required" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="form-unit">${text('区域价格信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('币种')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="currency" dictType="sys_bizhong" class="form-control required" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('参考单价')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="referencePrice" class="form-control number"/>
							</div>
						</div>
					</div>
				</div>
				<div class="form-unit">${text('配置信息')}</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('基本配置')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:input path="basicConfiguration" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<h4 class="form-unit">${text('配置信息')}</h4>
				<div class="ml10 mr10">
					<table id="tcarConfigurationDataGrid"></table>
					<% if (hasPermi('base:cars:tcar:edit')){ %>
						<a href="#" id="tcarConfigurationDataGridAddRowBtn" class="btn btn-primary btn-sm mt10 mb10"><i class="fa fa-plus"></i> ${text('增行')}</a>
					<% } %>
				</div>
                <div class="form-unit">${text('系统信息')}</div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('创建日期')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="createDate" class="form-control" disabled="true"
                                dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('创建人')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <!--<#form:input path="createBy" class="form-control" disabled="true"/>-->
                                <#form:select path="createBy" items="${listUser}" disabled="true"
                                itemLabel="userName" itemValue="userCode"  blankOption="true" class="form-control"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('最后修改日期')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="updateDate" readonly="true" maxlength="20" class="form-control"
                                dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('最后修改人')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <!--<#form:input path="updateBy" readonly="true" maxlength="20" class="form-control"/>-->
                                <#form:select path="updateBy" items="${listUser}" disabled="true"
                                itemLabel="userName" itemValue="userCode"  blankOption="true" class="form-control"/>
                            </div>
                        </div>
                    </div>
                </div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('base:cars:tcar:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
//初始化车辆管理-配置信息DataGrid对象
$("#tcarConfigurationDataGrid").dataGrid({
	data: ${toJson(tcar.tcarConfigurationList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'configurationId', editable:true, hidden:true},
		//{header:'${text("序号")}', name:'configurationId', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'64', 'class':'form-control required'}},
		{header:'${text("可选配置项目")}', name:'optionalConfigurationItem', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
		{header:'${text("英文名称")}', name:'englishName', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
		{header:'${text("编码")}', name:'code', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
		{header:'${text("价格")}', name:'price', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("车辆ID")}', name:'carId.carId', editable:true, hidden:true},
		{header:'${text("操作")}', name:'actions', width:80, sortable:false, fixed:true, formatter: function(val, obj, row, act){
			var actions = [];
			if (val == 'new'){
				actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#tcarConfigurationDataGrid\').dataGrid(\'delRowData\',\''+obj.rowId+'\')});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
			}else{
				actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#tcarConfigurationDataGrid\').dataGrid(\'setRowData\',\''+obj.rowId+'\',null,{display:\'none\'});$(\'#'+obj.rowId+'_status\').val(\''+Global.STATUS_DELETE+'\');});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
			}
			return actions.join('');
		}, editoptions: {defaultValue: 'new'}}
	],
	
	// 编辑表格参数
	editGrid: true,				// 是否是编辑表格
	editGridInitRowNum: 0,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#tcarConfigurationDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowInitData: {configurationId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据
	
	// 编辑表格的提交数据参数
	editGridInputFormListName: 'tcarConfigurationList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,configurationId,optionalConfigurationItem,englishName,code,price,carId.carId,', // 提交数据列表的属性字段
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>